package com.bzframework.pro;

import com.bzframework.pro.authorize.annotation.EnableAopAuthorization;
import lombok.extern.slf4j.Slf4j;
import org.hswebframework.web.crud.annotation.EnableEasyormRepository;
import org.hswebframework.web.logging.aop.EnableAccessLogger;
import org.hswebframework.web.logging.events.AccessLoggerAfterEvent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@SpringBootApplication(scanBasePackages = {
        "com.bzframework.pro",
        "com.bzframework.project",
},exclude = {
//        RedisAutoConfiguration.class,
//        DataSourceAutoConfiguration.class,
})
@EnableEasyormRepository({
        "com.bzframework.project.**.entity",
        "com.bzframework.pro.**.entity",
})
@EnableAccessLogger
@EnableAopAuthorization
public class ReactiveApplication {

    public static void main(String[] args) {
        SpringApplication.run(ReactiveApplication.class, args);
    }

    @Component
    @Slf4j
    public static class AccessLogger {

        @EventListener
        public void handleAccessLogger(AccessLoggerAfterEvent event) {

            log.info("{}=>{} {}-{}", event.getLogger().getIp(), event.getLogger().getUrl(), event.getLogger().getDescribe(), event.getLogger().getAction());

        }

    }

}
